package scenic.toolkit;

import java.awt.geom.Point2D;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import scenic.Graphics;
import scenic.Image;

public class CImage extends CComponent {
	private Image image;
	
	public CImage(String file) throws IOException {
		image  = new Image(ImageIO.read(new File(file)));
	}
	
	public CImage(Image image) {
		if(image == null)
			throw new IllegalArgumentException();
		this.image = image;
	}
	
	public void setImage(Image image) {
		if(image == null)
			throw new IllegalArgumentException();
		this.image = image;
	}
	
	public Image getImage() {
		return image;
	}
	
	public void paint(Graphics g) {
		g.drawImage(image);
	}
	
	public Point2D getMinimumSizeFor(double width, double height) {
		return new Point2D.Double(image.getWidth(), image.getHeight());
	}
}
